<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>签到/签退</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<!-- <link rel="stylesheet" type="text/css" href="../css/app.css" /> -->
		<style>
			h5 {
				margin: 5px 7px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">签到/签退</h1>
		</header>
		<div class="mui-content" style="">
			<div id="form" class="mui-content-padded" style="margin: 5px;">
				<form class="mui-input-group">
					<input id="signInId" type="hidden"/>
					<div class="mui-input-row">
						<label>姓名</label>
						<input id="name" type="text" readonly>
					</div>
					<div class="mui-input-row">
						<label>电话</label>
						<input id="loginname" type="text" readonly>
					</div>
					<div class="mui-input-row">
						<label>部门</label>
						<input id="organizationName" type="text" readonly>
					</div>
					<div class="mui-input-row">
						<label>签到</label>
						<input id="upRet" type="text" readonly>
					</div>
					<div class="mui-input-row">
						<label>签到时间</label>
						<input id="upTime" type="text" readonly>
					</div>
					<div class="mui-input-row">
						<label>签退</label>
						<input id="downRet" type="text" readonly>
					</div>
					<div class="mui-input-row">
						<label>签退时间</label>
						<input id="downTime" type="text" readonly>
					</div>
				</form>
			</div>
		</div>
		<script type="text/javascript" src="../js/jquery1113.js"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/util.js"></script>
		<script src="../js/data.js"></script>
		<script>
			var classId,className,stampId,stampName;
			mui.init({
				swipeBack: true //启用右滑关闭功能
			});
			mui.plusReady(function() {
				self = plus.webview.currentWebview();
				classId = self.classId;
				className = self.className;
				stampId = self.stampId;
				stampName = self.stampName;
				$(".mui-title").html(className+"("+stampName+")")
				getSignIn();
			});
			function getSignIn(){
				var name = plus.storage.getItem('name');
				var password = plus.storage.getItem('password');
									
				if(name != null && name != '' && password != null && password != '' & stampId != null && stampId != null){
					
					var jsonObject = {};
					jsonObject['name'] = name;
					jsonObject['password'] = password;
					jsonObject['stampId'] = stampId;
					
					xhr = new plus.net.XMLHttpRequest();
					xhr.onreadystatechange = function() {
						if(xhr.readyState == 4 && xhr.status == 200){
							var data = JSON.parse(xhr.responseText);
							if (data && data.result == 1 && data.data) {
								var signIn = data.data;
								$("#signInId").val(signIn.id);
								$("#name").val(signIn.user.name);
								$("#loginname").val(signIn.user.loginname);
								$("#organizationName").val(signIn.organizationName);
								if(signIn.upRet == 1){
									$("#upRet").val("已签到");
								} else if(signIn.upRet == 0){
									$("#upRet").val("未签到");
								} else if(signIn.upRet == 2){
									$("#upRet").val("迟到");
								}
								if(signIn.downRet == 1){
									$("#downRet").val("已签退");
								} else if(signIn.downRet == 0){
									$("#downRet").val("未签退");
								} else if(signIn.downRet == 2){
									$("#downRet").val("早退");
								}
								$("#upTime").val(signIn.upTime);
								$("#downTime").val(signIn.downTime);
							} else {
								mui.alert(data.message);
							}
						}
					}
					xhr.open("POST", serverUrl + "signIn/PubGetSignInByStampId.do");
					xhr.setRequestHeader("Content-Type", "application/json");
					xhr.send(JSON.stringify(jsonObject));
				}
			}
		</script>
	</body>

</html>